-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use semver gte comparison on polyfill version tester #12783
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/40094/ |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 6b8ed33:
|
22387b8
to
94a25f1
Compare
babel.config.js
Outdated
// semverGte("8.9", "8.9") // true | ||
// semverGte("9.0", "8.9") // true | ||
// semverGte("8.9", "8.10") // false | ||
`((v,w)=>(v=v.split("."),w=w.split("."),+v[0]>+w[0]||v[0]==w[0]&&+v[1]>=+w[1]))`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this expression be here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was meant for documentation of a stringified function only. 🤦♂️
I didn't figure out how to use @babel/template
so it can import the function defined here, but since we only used it twice, I am good with copying this function so far.
// semverGte("8.9", "8.10") // false | ||
// TODO: figure out how to inject it to the `@babel/template` usage so we don't need to | ||
// copy and paste it. | ||
// `((v,w)=>(v=v.split("."),w=w.split("."),+v[0]>+w[0]||v[0]==w[0]&&+v[1]>=+w[1]))`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could to
const semverGte = template.ast`(v,w)=>(v=v.split("."),w=w.split("."),+v[0]>+w[0]||v[0]==w[0]&&+v[1]>=+w[1])`
And then use it with interpolations in the other templates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok it looks like I was wrong, because we are not using template.ast
here but the version that returns a factory function 😅
Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
This reverts commit 2db2c3a.
semverGte
with examplesCurrently we use
parseFloat
(#12458) to compare node versions and to apply polyfills conditionally, however it will fail, for example, on comparing10.8
to10.12
, which is the case in #12650.The following affected packages should be republished:
@babel/cli
@babel/node
@babel/register
We don't need to republish
@babel/transfrom-runtime
since onlyscripts
is modified and we never build Babel on Node.js 10.